﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CP2011_Assignment
{
    public partial class CreateInv : Form
    {
        InventorySystem invSys = new InventorySystem();

        public CreateInv()
        {
            InitializeComponent();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {

            addingRecord(new InventorySystem());
            
            MessageBox.Show("New Item Successfuly Added!");
            this.Hide();
            Owner.Show();
            this.Close();
        }

        /// <summary>
        /// to preserve Dependency Inversion Principle
        /// </summary>
        /// <param name="dataCtrl"></param>
        private void addingRecord(IDataController dataCtrl)
        {
            ///create new inventory object 
            Inventory inv = new Inventory(txtInventoryName.Text, txtDescription.Text, Convert.ToInt32(txtMaxQuant.Text), Convert.ToInt32(txtSupplier.Text));
            dataCtrl.addToDatabase(inv);
        }

       
    }
}
